Skip to content

Conversation

@IKEYCY
Copy link
Contributor

@IKEYCY IKEYCY commented Nov 26, 2025

PR

PR Checklist

Please check if your PR fulfills the following requirements:

  • The commit message follows our Commit Message Guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

What is the current behavior?

Issue Number: N/A

What is the new behavior?

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

Summary by CodeRabbit

  • New Features

    • Added a round-corner option for the Tag component, enabling rounded borders across tag types and an icon-only variant.
  • Documentation / Demos

    • Added a new demo showcasing round-styled tags with examples and descriptions in Chinese and English.
  • Tests

    • Added end-to-end tests validating round styling is applied and visible across tag variants.

✏️ Tip: You can customize this high-level summary in your review settings.

@github-actions github-actions bot added the enhancement New feature or request (功能增强) label Nov 26, 2025
@coderabbitai
Copy link

coderabbitai bot commented Nov 26, 2025

Walkthrough

Added a new boolean round prop to the Tag component to enable rounded styling; updated core props and pc renderer, added demos (SFC and Composition API), a Playwright test, and API/webdoc entries for the new prop and demo.

Changes

Cohort / File(s) Change Summary
Core props
packages/vue/src/tag/src/index.ts
Added public prop round (type: Boolean, default: false).
Component implementation
packages/vue/src/tag/src/pc.vue
Apply tiny-tag--round CSS class when round is truthy and set inline borderRadius: 9999px.
Demos (SFC & Composition API)
examples/sites/demos/pc/app/tag/round.vue, examples/sites/demos/pc/app/tag/round-composition-api.vue
New demo components showing round-styled tags across types and an icon-only variant.
Demo registration / webdoc
examples/sites/demos/apis/tag.js, examples/sites/demos/pc/app/tag/webdoc/tag.js
Added round prop documentation and a new demo entry (demoId: "round") with descriptions and pcDemo metadata.
Tests
examples/sites/demos/pc/app/tag/round.spec.ts
New Playwright test asserting the round styling class presence on demo tags.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Areas to check:
    • Consistency between prop declaration and pc.vue usage (prop name, default).
    • CSS class name (tiny-tag--round) and inline style (borderRadius: 9999px) effect across browsers.
    • Demo and webdoc wiring (demoId, codeFiles, api.props) and test selector robustness.

Poem

🐇 A rounded hop, a ribbon bright,
I nibble code by lantern light,
Tags curl soft with gentle cheer,
Demos sparkle — testers cheer! ✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main change: adding a round prop to the tag component for circular border radius styling.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🧹 Nitpick comments (1)
examples/sites/demos/pc/app/tag/round.vue (1)

5-14: Consider simplifying boolean prop syntax.

The explicit :round="true" and :only-icon="true" syntax works correctly but can be simplified. In Vue, boolean props can be set using shorthand syntax.

Apply this diff for cleaner code:

-    <tiny-tag type="primary" :round="true">圆角标签</tiny-tag>
-    <tiny-tag type="success" :round="true">成功标签</tiny-tag>
-    <tiny-tag type="warning" :round="true">警告标签</tiny-tag>
-    <tiny-tag type="danger" :round="true">危险标签</tiny-tag>
+    <tiny-tag type="primary" round>圆角标签</tiny-tag>
+    <tiny-tag type="success" round>成功标签</tiny-tag>
+    <tiny-tag type="warning" round>警告标签</tiny-tag>
+    <tiny-tag type="danger" round>危险标签</tiny-tag>
 
-    <tiny-tag type="info" :round="true" :only-icon="true">
+    <tiny-tag type="info" round only-icon>
       <template #default>
         <icon-heartempty />
       </template>
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 94f7b91 and 28b9556.

📒 Files selected for processing (7)
  • examples/sites/demos/apis/tag.js (1 hunks)
  • examples/sites/demos/pc/app/tag/round-composition-api.vue (1 hunks)
  • examples/sites/demos/pc/app/tag/round.spec.ts (1 hunks)
  • examples/sites/demos/pc/app/tag/round.vue (1 hunks)
  • examples/sites/demos/pc/app/tag/webdoc/tag.js (1 hunks)
  • packages/vue/src/tag/src/index.ts (1 hunks)
  • packages/vue/src/tag/src/pc.vue (4 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: PR E2E Test (pnpm test:e2e3)
🔇 Additional comments (6)
packages/vue/src/tag/src/index.ts (1)

46-49: LGTM! Prop definition follows established patterns.

The round prop is correctly defined as a Boolean with a sensible default value of false, consistent with other boolean props in the component.

packages/vue/src/tag/src/pc.vue (4)

36-37: LGTM! Prop added to component declaration.

The round prop is correctly added to the component's props array.


57-58: LGTM! Prop correctly destructured.

The round prop is properly extracted from the component instance for use in the render function.


70-71: LGTM! CSS class conditionally applied.

The tiny-tag--round class is correctly applied when the round prop is truthy, following the existing pattern for other conditional classes.


88-90: LGTM! Border radius implementation is correct.

Setting borderRadius: '9999px' is a standard technique for creating fully rounded (pill-shaped) elements, as the large value ensures the ends are circular regardless of the element's height.

examples/sites/demos/pc/app/tag/webdoc/tag.js (1)

117-140: LGTM! Demo entry properly structured.

The webdoc entry for the round feature is correctly structured and consistent with other demo entries in the file.

Comment on lines +183 to +186
desc: {
'zh-CN': '是否为圆角的模式',
'en-US': 'Whether it is a circular mode'
},
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Clarify the English description.

The English description "Whether it is a circular mode" is ambiguous. "Circular" suggests a circle shape, but round here refers to rounded corners (border-radius). The Chinese "圆角" correctly translates to "rounded corners."

Apply this diff to improve clarity:

           desc: {
             'zh-CN': '是否为圆角的模式',
-            'en-US': 'Whether it is a circular mode'
+            'en-US': 'Whether to enable rounded corners'
           },
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
desc: {
'zh-CN': '是否为圆角的模式',
'en-US': 'Whether it is a circular mode'
},
desc: {
'zh-CN': '是否为圆角的模式',
'en-US': 'Whether to enable rounded corners'
},
🤖 Prompt for AI Agents
In examples/sites/demos/apis/tag.js around lines 183 to 186, the English
description "Whether it is a circular mode" is ambiguous; replace it with a
clear phrase that matches the Chinese "圆角" meaning rounded corners (e.g.,
"Whether it has rounded corners" or "Enable rounded corners"). Update the
'en-US' value to the chosen clear phrasing and keep the existing 'zh-CN' value
unchanged.

Comment on lines +16 to +21
<script setup>
import { TinyTag } from '@opentiny/vue'
import { IconHeartempty } from '@opentiny/vue-icon'
const tinyIconHeartempty = IconHeartempty()
</script>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Remove unused variable or register the component properly.

The variable tinyIconHeartempty is initialized but never used. The template directly references <tiny-icon-heartempty /> without explicit component registration, which may rely on auto-registration behavior.

Consider one of these solutions:

Option 1: Remove the unused variable and import (if auto-registration works):

 <script setup>
 import { TinyTag } from '@opentiny/vue'
-import { IconHeartempty } from '@opentiny/vue-icon'
-
-const tinyIconHeartempty = IconHeartempty()
 </script>

Option 2: Register and use the component explicitly:

 <script setup>
 import { TinyTag } from '@opentiny/vue'
 import { IconHeartempty } from '@opentiny/vue-icon'
 
-const tinyIconHeartempty = IconHeartempty()
+const TinyIconHeartempty = IconHeartempty()
 </script>
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<script setup>
import { TinyTag } from '@opentiny/vue'
import { IconHeartempty } from '@opentiny/vue-icon'
const tinyIconHeartempty = IconHeartempty()
</script>
<script setup>
import { TinyTag } from '@opentiny/vue'
</script>
🤖 Prompt for AI Agents
In examples/sites/demos/pc/app/tag/round-composition-api.vue around lines 16 to
21, the variable tinyIconHeartempty is created but never used while the template
expects a <tiny-icon-heartempty /> component; either remove the unused
IconHeartempty import and tinyIconHeartempty constant (if relying on
auto-registration) or explicitly register the component and use the variable
(e.g., register IconHeartempty as tiny-icon-heartempty in the component context
or expose tinyIconHeartempty for the template) so the template reference matches
a registered component.

Comment on lines 41 to 56
test('round 属性样式验证', async ({ page }) => {
page.on('pageerror', (exception) => expect(exception).not.toBeNull())
await page.goto('tag#round-usage')

// 验证所有具有round属性的标签都具有正确的圆角样式
const roundTags = page.locator('.tiny-tag')
const count = await roundTags.count()

for (let i = 0; i < count; i++) {
const tag = roundTags.nth(i)
await expect(tag).toHaveCSS('border-radius', '9999px')
}

// 验证标签数量是否正确
expect(count).toBe(6) // 4个基础标签 + 1个图标标签 + 1个配置标签
})
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Test count expectation is incorrect.

Line 55 expects 6 tags, but the demos (round.vue and round-composition-api.vue) only contain 5 tags:

  • 4 basic tags (圆角标签, 成功标签, 警告标签, 危险标签)
  • 1 icon-only tag

The comment references "1个配置标签" (1 config tag) that doesn't exist.

Update the expected count or add the missing tag:

-  // 验证标签数量是否正确
-  expect(count).toBe(6) // 4个基础标签 + 1个图标标签 + 1个配置标签
+  // 验证标签数量是否正确
+  expect(count).toBe(5) // 4个基础标签 + 1个图标标签
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
test('round 属性样式验证', async ({ page }) => {
page.on('pageerror', (exception) => expect(exception).not.toBeNull())
await page.goto('tag#round-usage')
// 验证所有具有round属性的标签都具有正确的圆角样式
const roundTags = page.locator('.tiny-tag')
const count = await roundTags.count()
for (let i = 0; i < count; i++) {
const tag = roundTags.nth(i)
await expect(tag).toHaveCSS('border-radius', '9999px')
}
// 验证标签数量是否正确
expect(count).toBe(6) // 4个基础标签 + 1个图标标签 + 1个配置标签
})
test('round 属性样式验证', async ({ page }) => {
page.on('pageerror', (exception) => expect(exception).not.toBeNull())
await page.goto('tag#round-usage')
// 验证所有具有round属性的标签都具有正确的圆角样式
const roundTags = page.locator('.tiny-tag')
const count = await roundTags.count()
for (let i = 0; i < count; i++) {
const tag = roundTags.nth(i)
await expect(tag).toHaveCSS('border-radius', '9999px')
}
// 验证标签数量是否正确
expect(count).toBe(5) // 4个基础标签 + 1个图标标签
})
🤖 Prompt for AI Agents
In examples/sites/demos/pc/app/tag/round.spec.ts around lines 41 to 56, the test
asserts expect(count).toBe(6) but the demos only render 5 tags; update the test
to match the source of truth by changing the expectation to
expect(count).toBe(5) (or alternatively add the missing config tag to the round
demo files if the intention is to keep 6), and run the spec to verify it passes.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 28b9556 and 5659acb.

📒 Files selected for processing (1)
  • examples/sites/demos/pc/app/tag/round.spec.ts (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: PR E2E Test (pnpm test:e2e3)
🔇 Additional comments (1)
examples/sites/demos/pc/app/tag/round.spec.ts (1)

7-8: LGTM!

The locator chain correctly targets tags within the demo container, and getting the count enables the dynamic assertion pattern.

import { test, expect } from '@playwright/test'

test('圆角', async ({ page }) => {
page.on('pageerror', (exception) => expect(exception).toBeNull())
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Improve error handling for better debugging.

Using expect(exception).toBeNull() will fail the test but hide the actual error details. Consider logging the exception or letting it propagate naturally for clearer failure messages.

Apply this diff to improve error visibility:

-  page.on('pageerror', (exception) => expect(exception).toBeNull())
+  page.on('pageerror', (exception) => {
+    throw new Error(`Unexpected page error: ${exception}`)
+  })

Or simply remove the handler to let errors fail the test naturally with full stack traces.

🤖 Prompt for AI Agents
In examples/sites/demos/pc/app/tag/round.spec.ts around line 4 the
page.on('pageerror', (exception) => expect(exception).toBeNull()) handler
swallows useful error details by asserting null; replace it with either removing
the handler so errors propagate naturally, or change it to log/throw the
exception (e.g., console.error(exception) and rethrow or call
fail(String(exception))) so test failures include the actual error message and
stack trace for debugging.

Comment on lines +10 to +11
// 动态创建与元素数量相同的期望数组
await expect(tags).toHaveClass(Array(count).fill(/tiny-tag--round/))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Test will pass with zero tags, losing validation effectiveness.

The dynamic assertion Array(count).fill(/tiny-tag--round/) creates an empty array when count = 0, causing toHaveClass([]) to pass without validating anything. Additionally, the previous version verified the actual border-radius CSS property, which is no longer checked.

Apply this diff to add meaningful validation:

   const tags = page.locator('.all-demos-container').locator('.tiny-tag')
   const count = await tags.count()
 
+  // Ensure at least one round tag exists
+  expect(count).toBeGreaterThan(0)
+
   // 动态创建与元素数量相同的期望数组
   await expect(tags).toHaveClass(Array(count).fill(/tiny-tag--round/))
+
+  // Verify the first tag has the expected border-radius
+  await expect(tags.first()).toHaveCSS('border-radius', '9999px')

This ensures:

  1. At least one tag is present
  2. All tags have the tiny-tag--round class
  3. The border-radius CSS property is actually applied
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// 动态创建与元素数量相同的期望数组
await expect(tags).toHaveClass(Array(count).fill(/tiny-tag--round/))
const tags = page.locator('.all-demos-container').locator('.tiny-tag')
const count = await tags.count()
// Ensure at least one round tag exists
expect(count).toBeGreaterThan(0)
// 动态创建与元素数量相同的期望数组
await expect(tags).toHaveClass(Array(count).fill(/tiny-tag--round/))
// Verify the first tag has the expected border-radius
await expect(tags.first()).toHaveCSS('border-radius', '9999px')
🤖 Prompt for AI Agents
In examples/sites/demos/pc/app/tag/round.spec.ts around lines 10-11, the test
currently uses Array(count).fill(/tiny-tag--round/) which passes when count is 0
and no CSS is validated; change the assertions to first assert that tags.length
is greater than 0, then assert that every tag element has the "tiny-tag--round"
class (not just an empty-array class check), and finally check the computed
style on a tag (e.g., getComputedStyle or equivalent) to verify the
border-radius value matches the expected rounded value; implement these three
checks in place of the current single toHaveClass line.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request (功能增强)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant